/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package Operaciones;

import ClasesTablas.Revista;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;

/**
 *
 * @author CHENTEHC
 */
public class BorrarRevista {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Session session = null;
        try{
            Configuration configuration=new Configuration();
            SessionFactory sessionFactory=configuration.configure().buildSessionFactory();
            session=sessionFactory.openSession();
            Transaction transaction=session.beginTransaction();
            
            Revista rev=new Revista();
            rev.setIdRevista(2);
            session.delete(rev);
            transaction.commit();
            System.out.println("Hecho!");
        }catch(Exception e){ 
            System.out.println(e.getMessage());
        }
        finally{
            session.flush();
            session.close();
        }
    }
        // TODO code application logic here
    }
    